Skip to content

chore(ci): build the E2E dev image with the GitHub Actions cache - #122

Merged
Rushaway merged 17 commits into
mainfrom
chore/ci-e2e-image-cache
Nov 29, 2026
Merged

Rushaway merged 17 commits into
mainfrom
chore/ci-e2e-image-cache

Conversation

@Rushaway

@Rushaway Rushaway commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Problem

docker compose up -d --wait builds the dev web image (docker/Dockerfile: apt packages, docker-php-ext-install) in every E2E run. On the PR #114 run that took 62 s of the 93 s Bring up the dev stack step, and with three shards (#120) it is paid three times (#115).

Change

  • docker/setup-buildx-action@v4 + docker/build-push-action@v7 build docker/Dockerfile with cache-from: type=gha,scope=e2e-dev-web, load: true, tagged sbpp-dev-web:latest (the image: name in docker-compose.yml). compose up then finds the image and skips its own build; the stack itself does not change.
  • Only shard 1 writes the cache (mode=max), so the shards do not race on it.
  • Since chore(ci): run PHPUnit and E2E nightly on main instead of on every push #117 a push to main no longer runs E2E, so the nightly run on main fills the cache scope that pull requests read (a PR first falls back to its own scope, then to main's).
  • Same versions as docker-image.yml.

Checked

  • actionlint: no finding.
  • CI run 46278720884 (cache written by the cancelled run before it): Build the dev web image 13-14 s (34 s on shard 1, which writes the cache), then Bring up the dev stack 12-14 s. Before: 108-128 s for the bring-up alone. E2E jobs 214 / 253 / 300 s, workflow wall 369 s -> 334 s.

Version

2.2.31 -> 2.2.32 (stacked on #121)

Merge order

Stack for #115, squash one at a time from the bottom:

  1. chore(ci): cancel the outdated run when a pull request is pushed again #116 chore(ci): cancel the outdated run on a new PR push (2.2.26)
  2. chore(ci): run PHPUnit and E2E nightly on main instead of on every push #117 chore(ci): PHPUnit + E2E nightly on main instead of on every push (2.2.27)
  3. perf(tests): seed the fixture admin with a precomputed password hash #118 perf(tests): precomputed fixture admin password hash (2.2.28)
  4. chore(ci): run the PHPUnit MariaDB on tmpfs without fsync #119 chore(ci): PHPUnit MariaDB on tmpfs without fsync (2.2.29)
  5. chore(ci): run the Playwright E2E suite as three parallel shards #120 chore(ci): Playwright E2E as three parallel shards (2.2.30)
  6. perf(tests): reset the fixture tables with DELETE instead of TRUNCATE #121 perf(tests): fixture reset with DELETE instead of TRUNCATE (2.2.31)
  7. chore(ci): build the E2E dev image with the GitHub Actions cache #122 chore(ci): E2E dev image built with the gha cache (2.2.32)
  8. fix(e2e): wait for the settings bounce in the password generator spec #123 fix(e2e): password generator spec waits for the settings bounce (2.2.33)

Every workflow that runs on pull requests gets a concurrency group keyed
on the PR number, with cancel-in-progress. Other events (push, tag,
schedule, manual) key on the run id, so they never cancel or queue
behind each other.

Refs #115
The merged commit already passed both suites on its pull request. A push
to main now runs only the fast gates (PHPStan, ts-check, API contract,
plugin build). PHPUnit and the Playwright E2E suite run on pull
requests, every night on main, and on demand.

Refs #115
Fixture::reset() runs before every test and re-seeded the admin row with
a fresh password_hash(). bcrypt costs 12 by default since PHP 8.4, about
0.22 s a hash, so ~1,770 resets spent most of the PHPUnit run hashing
the same password. The hash is now computed once per process.

BansTest (80 tests) locally: 24 s -> 8 s, same assertions.

Refs #115
Fixture::reset() truncates and re-seeds every table before each test,
so the job was bound by fsync. MariaDB now starts from a step (a service
container cannot pass server options) with its datadir on tmpfs,
innodb_flush_log_at_trx_commit=0, no doublewrite buffer and no binlog.
It boots while PHP and Composer install, listens on a free loopback
port, has a per-run name, and is removed when the job ends, so a
self-hosted runner keeps no leftover container.

BansTest (80 tests) locally: 43-49 s on disk -> 8-9 s on tmpfs.

Refs #115
The suite ran on one worker because every spec shares the
sourcebans_e2e database. Each shard now brings up its own dev stack and
database and runs --shard=N/3, so workers: 1 no longer sets the total
time. From the per-test durations of the PR #114 run (428 s of tests),
the three contiguous slices carry 158 / 132 / 138 s. fail-fast is off,
so a red run still lists every failing spec, and on failure a report job
merges the shards' blob reports into the usual playwright-report
artifact.

Refs #115
Hashing once per process still cost 0.22 s in every
#[RunInSeparateProcess] child (165 tests) and on every E2E reset, which
runs in a fresh process. The fixture now seeds a precomputed cost-12
bcrypt hash of 'admin': same password, cost and format, and
password_needs_rehash() stays false.

Refs #115
TRUNCATE is DDL that recreates each tablespace: 27 of them took 65-125
ms per reset on MariaDB 10.11 with a tmpfs datadir, and the reset runs
before every test. The fixture now DELETEs every table and runs
ALTER TABLE ... AUTO_INCREMENT = 1 only where information_schema shows
the counter moved (MySQL 8's cached value is switched off for the
session). Same end state, ~12 ms per reset. The E2E reset shim shares
this code.

Full suite locally (tmpfs DB): 235 s -> 176 s, same 1,770 tests.

Refs #115
Every E2E shard built the dev web image from scratch inside
docker compose up (62 s of the 93 s bring-up on the PR #114 run). The
image is now built by buildx with the gha cache under the tag
docker-compose.yml uses, so compose finds it and skips its build. Only
shard 1 writes the cache; the nightly run on main fills the scope that
pull requests read.

Refs #115
@Rushaway Rushaway added priority: medium Normal priority chore Build, tests or tooling, no user-facing change area: ci GitHub Actions workflows and test harness labels Nov 29, 2026
@Rushaway
Rushaway marked this pull request as ready for review November 29, 2026 15:40
@Rushaway
Rushaway merged commit 0c453db into main Nov 29, 2026
2 checks passed
@Rushaway
Rushaway deleted the chore/ci-e2e-image-cache branch November 29, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci GitHub Actions workflows and test harness chore Build, tests or tooling, no user-facing change priority: medium Normal priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant